// 简写前
class Person {
    public name: string
    public age: number
    constructor(name: string, age: number) {
        this.name = name;
        this.age = age;
    }
    speak() {
        console.log(`${this.name} says hello${this.age}.`);
    }
}
// 简写后
class Person1 {
    constructor(public name: string, public age: number) {
    }
    speak() {
        console.log(`${this.name} says hello${this.age}.`);
    }
}
class Student extends Person {
    grade: number
    constructor(name: string, age: number, grade: number) {
        super(name, age);
        this.grade = grade;
    }
    study() {
        console.log(`${this.name} is studying.`);
    }
    override speak() {
        console.log(`${this.name} is studying in grade ${this.grade}.`);
    }
}

let p = new Person("Alice", 25);
p.speak(); // output: Alice says hello25.

let p1 = new Person("Alice1", 25);
p1.speak(); // output: Alice1 says hello25.

let s = new Student("Bob", 20, 3);
s.study(); // output: Bob is studying.
s.speak(); // output: Bob is studying in grade 3.

interface Person2 {
    name: string
    age: number
}
const pp: Person2 = {
    name: "Alice2",
    age: 25,
    grade: 3
}
console.log(pp.name)
console.log(pp.grade)
interface Person2 {
    grade: number
}